package com.xx.happychatboot.serve.room.domain.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import com.xx.happychatboot.base.enums.NormalOrNoEnum;
import io.mybatis.provider.Entity;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 单聊房间表
 * </p>
 *
 * @author xiaoXuan
 * @since 2025-01-02
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Entity.Table("room_friend")
public class RoomFriend implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @Entity.Column(id = true, remark = "主键", updatable = false, insertable = false)
    private Long id;

    /**
     * 房间id
     */
    @Entity.Column("room_id")
    private Long roomId;

    /**
     * uid1（更小的uid）
     */
    @Entity.Column("uid1")
    private Long uid1;

    /**
     * uid2（更大的uid）
     */
    @Entity.Column("uid2")
    private Long uid2;

    /**
     * 房间key由两个uid拼接，先做排序uid1_uid2
     */
    @Entity.Column("room_key")
    private String roomKey;

    /**
     * 房间状态 0正常 1禁用(删好友了禁用)
     */
    @Entity.Column("status")
    private Integer status;

    /**
     * 创建时间
     */
    @Entity.Column("create_time")
    private Date createTime = new Date();

    /**
     * 修改时间
     */
    @Entity.Column("update_time")
    private Date updateTime = new Date();

    public static RoomFriend buildFriendRoom(Long roomId, Long uid, Long targetId,String key) {
        RoomFriend roomFriend = new RoomFriend();
        roomFriend.setRoomId(roomId);
        roomFriend.setUid1(uid);
        roomFriend.setUid2(targetId);
        roomFriend.setRoomKey(key);
        roomFriend.setStatus(NormalOrNoEnum.NORMAL.getStatus());
        return roomFriend;
    }
}
